﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service
{
    public class ContactInfoService: IService<ContactInfo>
    {
        private readonly GenericRepository<ContactInfo> _contactInfoRepository;
        private readonly IUnitOfWork _unitOfWork;

        public ContactInfoService(IUnitOfWork unitOfWork, GenericRepository<ContactInfo> contactInfoRepository)
        {
            this._contactInfoRepository = contactInfoRepository;
            this._unitOfWork = unitOfWork;
        }


        public IQueryable<ContactInfo> GetAllElements()
        {
            return _contactInfoRepository.GetAll();
        }

        public ContactInfo GetElementById(int id)
        {
            return _contactInfoRepository.GetById(id);
        }

        public void CreateElement(ContactInfo entity)
        {
            _contactInfoRepository.Insert(entity);
        }

        public void UpdateElement(ContactInfo entity)
        {
            _contactInfoRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _contactInfoRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
